package com.infore.water.intercepor;


import com.infore.water.util.HttpUtil;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.InetAddress;
import java.util.Enumeration;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 * @author :wk
 */
public class LoginInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//		String user = request.getHeader("userName");
//		String userId = request.getHeader("userId");
//		String token = request.getHeader("token");
//		if(request.getRequestURI().contains("login")){
//			return true;
//		}
//		Element e = ehcache.get(userId);
//		if (e!=null&&token.equals(e.getObjectValue())) {
//		HttpSession obj =  request.getSession();
//		System.out.println(new Gson().toJson(request.getCookies()));
//		System.out.println(InetAddress.getLocalHost().getHostAddress());
//		System.out.println(HttpUtil.getVisitorIp(request));
//		System.out.println(request.getContentType());
//		System.out.println(request.getRequestURI());User-Agent
		System.out.println(request.getRequestURL());
		return true;
//		}
//		return false;
	}

}
	